package tech.aistar.mapper.comment;


import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tech.aistar.entity.Comment;

import java.util.List;

/**
 * Created by Administrator on 2019/9/27 0027.
 */
@Repository
public interface CommentMapper {
    @Select("select * from comment")
    List<Comment> comFindAll();


    @Select("select * from comment where level=#{value}")
    List<Comment> comFindOne(Integer level);

    @Select("select c.id,c.service_id,c.answer_id,c.time,c.content,c.userinfo_id,c.counts from comment c join user_info u on u.id = c.userinfo_id where service_id=#{value} ")
    List<Comment> comFindser(Integer serviceId);

    @Update("update comment set status = 1 where id = #{value}")
    void comdelById(Integer id);

    @Update("update comment set counts = counts + 1 where id = #{value}")
    void comCounts(Integer id);

    //添加
    @Insert("insert into comment(userinfo_id,time,level,content,status,url) values(#{userinfoId},#{time},#{level},#{content},#{status},#{url)")
    void praiseSave(Comment comment);
}
